﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jumpton.SFA.Server.BusinessRule.MasterData;
using Jumpton.SFA.Server.Entity;
using Jumpton.Persistent;
using BusinessRule.System;

public partial class ThirdParty_Compnies_List : PageBase
{
    ObjectTable ot;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitForm();
            btnSrh_Click(sender, e);
        }
    }

    private void InitForm()
    {
        //GetManuType();
        //GetCategoryType();
        //GetBrandType();
    }

    protected void btnSrh_Click(object sender, EventArgs e)
    {
        GetFormBind();
    }


    private void GetFormBind()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (txtAdd.Text.Trim() != "") sb.Append(" and ADDRESS like '%" + txtAdd.Text.Trim() + "%'");
        if (txtCode.Text.Trim() != "") sb.Append(" and CODE like '%" + txtCode.Text.Trim() + "%'");
        if (txtContact.Text.Trim() != "") sb.Append(" and CONTACT like '%" + txtContact.Text.Trim() + "%'");
        if (txtName.Text.Trim() != "") sb.Append(" and NAME like '%" + txtName.Text.Trim() + "%'");
        if (txtTel.Text.Trim() != "") sb.Append(" and (TEL like '%" + txtTel.Text.Trim() + "%' or MOBILE  like '%" + txtTel.Text.Trim() + "%')");
        sb.Append(" and ACTIVE = "+ (chkActive.Checked?1:0));
        GridPager1.DataSource = new ThirdPartyCompaniesManager().GetThirdPartyCompanies(MyStateManager.DomainID,sb.ToString());
        GridPager1.GridView = GridView1;
        GridPager1.BindData();
        GridPager1.Visible = GridView1.Rows.Count > 0;

    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GetFormBind();
    }
}
